package com.iwdm.renovation.ui.cart;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.iwdm.renovation.databinding.FragmentCartItemBinding;


public class MyCartRecyclerViewAdapter extends RecyclerView.Adapter<MyCartRecyclerViewAdapter.ViewHolder> {
    FragmentCartItemBinding binding;
    private boolean isChecked = false;

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        binding = FragmentCartItemBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
        return new ViewHolder(binding);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.radio.setChecked(isChecked);
//        holder.radio.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//                holder.radio.setChecked(holder.radio.isChecked());
//
//            }
//        });
    }


    @Override
    public int getItemCount() {
        return 8;
    }

    public void setAllChecked(boolean isChecked) {
        this.isChecked = isChecked;
        notifyDataSetChanged();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        public final View mView;
        public boolean isdianzan = true;
        public RadioButton radio;

        public ViewHolder(FragmentCartItemBinding binding) {
            super(binding.getRoot());
            mView = binding.getRoot();
            radio = binding.radio;
        }
    }
}
